<?php
/**
 * User: 1971229701@qq.com
 * Date: 2020/10/13/013
 * Time: 13:20
 */

namespace app\common\logic;


use OSS\Core\OssException;
use OSS\OssClient;

class AliOss
{
    const endpoint = 'oss-cn-beijing.aliyuncs.com';
    const accessKeyId = 'LTAI4Fz3VrQ3XArM2PoXdVvV';
    const accessKeySecret = 'blu2H7mKjoITDw2iMyu7e5r1jlY1Hi';
    const bucket = 'zhongchengcar';

    /**
     * 根据Config配置，得到一个OssClient实例
     *
     * @return OssClient 一个OssClient实例
     */
    public static function getOssClient()
    {
        try {
            $ossClient = new OssClient(self::accessKeyId, self::accessKeySecret, self::endpoint, false);
        } catch (OssException $e) {
            printf(__FUNCTION__ . "creating OssClient instance: FAILED\n");
            printf($e->getMessage() . "\n");
            return null;
        }
        return $ossClient;
    }

    public static function getBucketName()
    {
        return self::bucket;
    }
}